﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tanmia.Basis;
using Tanmia.Core;
using NHibernate;
using NHibernate.Criterion;

namespace Tanmia.NHibernate
{
    public class ItemRepository : Repository<Item>
    {
        public IList<Item> GetsItemsInDiscriminatedItem()
        {
            ISession session = SessionFactory.Session;

            var subQuery = QueryOver.Of<DiscriminatedItem>()
                .Select(x => x.Item.ItemID);

            var result = session.QueryOver<Item>()
                .WithSubquery.WhereProperty(x => x.ItemID).In(subQuery)
                .List<Item>();
            return result;
        }

    }
}
